package com.lm.jsoup.example;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

public class JsoupCssSelector {
    public static void main(String[] args) {
        String html = "<html><body>" +
                "<div class='content'><h1>Header</h1><p>Paragraph 1</p></div>" +
                "<div class='footer'><p>Footer Paragraph</p></div>" +
                "</body></html>";

        // 解析 HTML
        Document document = Jsoup.parse(html);

        // 使用 CSS 选择器提取内容
        Elements content = document.select(".content h1");
        System.out.println("Header: " + content.text());

        Elements footer = document.select(".footer p");
        System.out.println("Footer: " + footer.text());
    }
}
